package com.tcwlkj.uuService.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.Button;

import com.tcwlkj.uuService.R;

/**
 * Created by Administrator on 2017/11/20 0020.
 */

public class TimeButtonCount extends CountDownTimer {
    private final Context baseContent;
    Button button;
    String orderId;
    public TimeButtonCount(Context content , long millisInFuture, long countDownInterval, Button bt,String orderId) {
        super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
        baseContent = content;
        this.button=bt;
        this.orderId=orderId;
    }
    @Override
    public void onFinish() {// 计时完毕时触发
        button.setText("重发验证码");
        button.setClickable(true);
        button.setTextColor(baseContent.getResources().getColor(R.color.mainText));
//        button.setBackgroundResource(R.drawable.btlogin);

       // ChcheUtils.getInstance().getIsYZMhash().put(orderId,true);

    }

    @Override
    public void onTick(long millisUntilFinished) {// 计时过程显示
        button.setClickable(false);
//        button.setBackgroundResource(R.drawable.bthui);
        button.setTextColor(baseContent.getResources().getColor(R.color.divider));
//        button.setText(millisUntilFinished / 1000 + " 秒后重发");
        button.setText(millisUntilFinished / 1000+"秒后重发");
        //button.append(" 秒后重发");
        ChcheUtils.getInstance().getHashMap_int().put(orderId,millisUntilFinished / 1000);
        if(millisUntilFinished / 1000==1){
           // ChcheUtils.getInstance().getYZMhashMap().put(orderId,true);
        }

    }
}
